/* may be null if not dirty */
cairo_region_t *surface_dirty;
- /* background tracking for rgb/rgba */
- GtkStyleContext *style_context;
-
guint timeout_tag;
guint extra_width;
guint extra_height;
guint always_cache : 1;
+ guint is_opaque : 1;
};
GtkPixelCache *
if (cache->surface_dirty != NULL)
cairo_region_destroy (cache->surface_dirty);
- g_clear_object (&cache->style_context);
-
g_free (cache);
}
content = cache->content;
if (!content)
{
- content = CAIRO_CONTENT_COLOR_ALPHA;
- if (cache->style_context &&
- gtk_css_style_render_background_is_opaque (gtk_style_context_lookup_style (cache->style_context)))
+ if (cache->is_opaque)
content = CAIRO_CONTENT_COLOR;
+ else
+ content = CAIRO_CONTENT_COLOR_ALPHA;
}
surface_w = view_rect->width;
}
void
-_gtk_pixel_cache_set_style_context (GtkPixelCache *cache,
- GtkStyleContext *style_context)
+gtk_pixel_cache_set_is_opaque (GtkPixelCache *cache,
+ gboolean is_opaque)
{
- if (g_set_object (&cache->style_context, style_context))
- _gtk_pixel_cache_invalidate (cache, NULL);
+ if (cache->is_opaque == is_opaque)
+ return;
+
+ cache->is_opaque = is_opaque;
+ _gtk_pixel_cache_invalidate (cache, NULL);
}
gboolean _gtk_pixel_cache_get_always_cache (GtkPixelCache *cache);
void _gtk_pixel_cache_set_always_cache (GtkPixelCache *cache,
gboolean always_cache);
-void _gtk_pixel_cache_set_style_context(GtkPixelCache *cache,
- GtkStyleContext *style_context);
+void gtk_pixel_cache_set_is_opaque (GtkPixelCache *cache,
+ gboolean is_opaque);
G_END_DECLS
#include "gtkmarshalers.h"
#include "gtkmenu.h"
#include "gtkmenuitem.h"
+#include "gtkrenderbackgroundprivate.h"
#include "gtkseparatormenuitem.h"
#include "gtksettings.h"
#include "gtkselectionprivate.h"
#include "gtkscrollable.h"
#include "gtktypebuiltins.h"
#include "gtktexthandleprivate.h"
-#include "gtkstylecontextprivate.h"
#include "gtkcssstylepropertyprivate.h"
#include "gtkpopover.h"
#include "gtktoolbar.h"
context = gtk_widget_get_style_context (GTK_WIDGET (text_view));
gtk_style_context_add_class (context, GTK_STYLE_CLASS_VIEW);
- _gtk_pixel_cache_set_style_context (priv->pixel_cache, context);
/* Set up default style */
priv->wrap_mode = GTK_WRAP_NONE;
GtkCssStyleChange *change,
GtkWidget *widget)
{
+ GtkTextViewPrivate *priv = GTK_TEXT_VIEW (widget)->priv;
+
if (gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_SIZE | GTK_CSS_AFFECTS_CLIP))
gtk_widget_queue_resize (widget);
else
gtk_widget_queue_draw (widget);
+
+ if (node == priv->text_window->css_node)
+ {
+ GtkCssStyle *style = gtk_css_style_change_get_new_style (change);
+ gtk_pixel_cache_set_is_opaque (priv->pixel_cache, gtk_css_style_render_background_is_opaque (style));
+ }
}
static void
#include "gtkpixelcacheprivate.h"
#include "gtkprivate.h"
#include "gtkscrollable.h"
-#include "gtkrender.h"
+#include "gtkrenderbackgroundprivate.h"
+#include "gtkstylecontextprivate.h"
#include "gtktypebuiltins.h"
#include "gtkwidgetprivate.h"
return FALSE;
}
+static void
+gtk_viewport_update_pixelcache_opacity (GtkWidget *child,
+ GtkViewport *viewport)
+{
+ GtkViewportPrivate *priv = viewport->priv;
+
+ gtk_pixel_cache_set_is_opaque (priv->pixel_cache,
+ gtk_css_style_render_background_is_opaque (
+ gtk_style_context_lookup_style (
+ gtk_widget_get_style_context (child))));
+}
+
static void
gtk_viewport_remove (GtkContainer *container,
GtkWidget *child)
GtkViewport *viewport = GTK_VIEWPORT (container);
GtkViewportPrivate *priv = viewport->priv;
- GTK_CONTAINER_CLASS (gtk_viewport_parent_class)->remove (container, child);
+ if (g_signal_handlers_disconnect_by_func (child, gtk_viewport_update_pixelcache_opacity, viewport) != 1)
+ {
+ g_assert_not_reached ();
+ }
- _gtk_pixel_cache_set_style_context (priv->pixel_cache, NULL);
+ GTK_CONTAINER_CLASS (gtk_viewport_parent_class)->remove (container, child);
+ gtk_pixel_cache_set_is_opaque (priv->pixel_cache, FALSE);
}
static void
g_return_if_fail (gtk_bin_get_child (bin) == NULL);
gtk_widget_set_parent_window (child, priv->bin_window);
-
- _gtk_pixel_cache_set_style_context (priv->pixel_cache,
- gtk_widget_get_style_context (child));
-
+
GTK_CONTAINER_CLASS (gtk_viewport_parent_class)->add (container, child);
+
+ g_signal_connect (child, "style-updated", G_CALLBACK (gtk_viewport_update_pixelcache_opacity), viewport);
+ gtk_viewport_update_pixelcache_opacity (child, viewport);
}
static void